package com.qgs.waf.gen;

import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisConnectionUtils;
import org.springframework.data.redis.core.RedisTemplate;

import com.google.gson.Gson;
import com.qgs.waf.jedis.RedisKeys;

public class GenAttackSummaryIndustryRelation {

	public static void test() {
		Gson gson = new Gson();
		ApplicationContext ac = new ClassPathXmlApplicationContext("classpath*:applicationContext*.xml", "classpath*:mybatis-*.xml");
		RedisTemplate rt = (RedisTemplate) ac.getBean("jedisTemplate");
		RedisConnectionFactory factory = rt.getConnectionFactory();
		RedisConnection redisConnection = RedisConnectionUtils.getConnection(factory);
		redisConnection.openPipeline();
		String industrys[] = new String[] { "金融", "法院", "政府", "住建","电力", "税务", "其他" };
		String jinrong[] = new String[] { "杭州拱墅区杭行路杭行路杭州银行分部" };
		String fayuan[] = new String[] { "杭州拱墅区人民法院", "杭州江干区人民法院", "杭州余杭区人民法院", "杭州余杭区人民法院","杭州西湖区人民法院", "温州鹿城区人民法院", "温州平阳人民法院" };
		String zhengfu[] = new String[] { "杭州拱墅区人民政府", "杭州余杭区人民政府", "温州鹿城区人民政府" };
		String zhujian[] = new String[] { "舟山市定海区住建局" };
		String dianli[] = new String[] { "国网浙江电力公司" };
		String shuiwu[] = new String[] { "杭州税务局", "杭州地税局" };
		String qita[] = new String[] { "浙江乾冠信息安全研究院" };
		redisConnection.hSet(RedisKeys.ATTACKSUMMARYINDUSTROYRELATION.getBytes(), industrys[0].getBytes(), gson.toJson(jinrong).getBytes());
		redisConnection.hSet(RedisKeys.ATTACKSUMMARYINDUSTROYRELATION.getBytes(), industrys[1].getBytes(),gson.toJson(fayuan).getBytes());
		redisConnection.hSet(RedisKeys.ATTACKSUMMARYINDUSTROYRELATION.getBytes(), industrys[2].getBytes(), gson.toJson(zhengfu).getBytes());
		redisConnection.hSet(RedisKeys.ATTACKSUMMARYINDUSTROYRELATION.getBytes(), industrys[3].getBytes(),gson.toJson(zhujian).getBytes());
		redisConnection.hSet(RedisKeys.ATTACKSUMMARYINDUSTROYRELATION.getBytes(), industrys[4].getBytes(), gson.toJson(dianli).getBytes());
		redisConnection.hSet(RedisKeys.ATTACKSUMMARYINDUSTROYRELATION.getBytes(), industrys[5].getBytes(),gson.toJson(shuiwu).getBytes());
		redisConnection.hSet(RedisKeys.ATTACKSUMMARYINDUSTROYRELATION.getBytes(), industrys[6].getBytes(), gson.toJson(qita).getBytes());
		List results = redisConnection.closePipeline();
		System.out.println(results);
		redisConnection.close();
		System.out.println("end ......");
	}

	public static void main(String[] args) {
		test();
	}

}
